home *** CD-ROM | disk | FTP | other *** search
/ Champak 49 / Volume 49 - JOGO DISK .iso / Games / honeytrouble.swf / scripts / frame_7 / DoAction.as
Encoding:
Text File  |  2007-09-27  |  13.1 KB  |  459 lines

  1. function pushGrid(obj, isnew)
  2. {
  3.    if(!obj.removing)
  4.    {
  5.       if(isnew || Math.floor(obj.oldx / grid_width) != Math.floor(obj._x / grid_width) || Math.floor(obj.oldy / grid_width) != Math.floor(obj._y / grid_width))
  6.       {
  7.          myGrid.pop(obj.oldx,obj.oldy,obj,"tgt_ball");
  8.          myGrid.push(obj._x,obj._y,obj,"tgt_ball");
  9.       }
  10.    }
  11. }
  12. function go(obj, frame)
  13. {
  14.    obj.roll_frame += frame;
  15.    obj.roll_frame %= obj.flower.roll_mc._totalframes;
  16.    obj.flower.roll_mc.gotoAndStop(Math.round(obj.roll_frame) + 1);
  17. }
  18. function dis_func(mc1, mc2)
  19. {
  20.    if(typeof mc1 != "movieclip")
  21.    {
  22.       var _loc4_ = mc1.x - mc2._x;
  23.       var _loc3_ = mc1.y - mc2._y;
  24.    }
  25.    else if(typeof mc2 != "movieclip")
  26.    {
  27.       _loc4_ = mc1._x - mc2.x;
  28.       _loc3_ = mc1._y - mc2.y;
  29.    }
  30.    else
  31.    {
  32.       _loc4_ = mc1._x - mc2._x;
  33.       _loc3_ = mc1._y - mc2._y;
  34.    }
  35.    dis = Math.sqrt(Math.pow(_loc4_,2) + Math.pow(_loc3_,2));
  36.    return dis;
  37. }
  38. function updatePos(obj, _speed, isNew)
  39. {
  40.    if(_root.ball_number_n == 0 && balls_num < 18)
  41.    {
  42.       now_type_tmp_arr = [];
  43.       for(var _loc7_ in tgt_mcs)
  44.       {
  45.          if(tgt_mcs[_loc7_].type < 7 && tgt_mcs[_loc7_].type != undefined && tgt_mcs[_loc7_].type != 11 && tgt_mcs[_loc7_].type != 9 && String(typeof tgt_mcs[_loc7_]).length != 0)
  46.          {
  47.             now_type_tmp_arr.push(tgt_mcs[_loc7_].type);
  48.          }
  49.       }
  50.    }
  51.    lost_pox = {x:pos_array[pos_array.length - 1].x,y:pos_array[pos_array.length - 1].y};
  52.    hold_mx.x = pos_array[pos_array.length - 3].x;
  53.    hold_mx.y = pos_array[pos_array.length - 3].y;
  54.    obj.oldx = int(obj._x);
  55.    obj.oldy = int(obj._y);
  56.    if(obj.pos < pos_array.length * lineXishu)
  57.    {
  58.       var _loc5_ = Math.floor(obj.pos / lineXishu);
  59.       var _loc8_ = obj.pos - _loc5_ * lineXishu;
  60.       var _loc6_ = new Object();
  61.       _loc6_.dx = _loc8_ * pos_array[_loc5_].dx;
  62.       _loc6_.dy = _loc8_ * pos_array[_loc5_].dy;
  63.       _loc6_.dr = _loc8_ * pos_array[_loc5_].dr;
  64.       obj._x = int(pos_array[_loc5_].x + _loc6_.dx);
  65.       obj._y = int(pos_array[_loc5_].y + _loc6_.dy);
  66.    }
  67.    if(holdBall_mc.hold_mc != undefined && obj.hitTest(holdBall_mc.hold_mc.trg))
  68.    {
  69.       if(_root.EndBall != obj)
  70.       {
  71.          hold_mx.num = hold_mx.num + 1;
  72.          var _loc2_ = [obj];
  73.          sp_xiqiu = true;
  74.          var _loc3_ = new Object();
  75.          _loc3_.tgt_remove_num = 0;
  76.          _loc3_.id = random(65535);
  77.          _loc3_.remove_array = _loc2_;
  78.          remove_arr_array[_loc3_.id] = _loc3_;
  79.          remove_sound.start(0);
  80.          i = 0;
  81.          while(i < _loc2_.length)
  82.          {
  83.             _loc2_[i].remove_id = _loc3_.id;
  84.             myGrid.pop(_loc2_[i]._x,_loc2_[i]._y,_loc2_[i],"tgt_ball");
  85.             _loc2_[i].removing = true;
  86.             _loc2_[i].gotoAndPlay("remove");
  87.             i++;
  88.          }
  89.          if(_root.ball == undefined)
  90.          {
  91.             _root.crtNewBall();
  92.          }
  93.          if(hold_mx.num >= 3)
  94.          {
  95.             _root.holdBall2 == false;
  96.             _root.holdBall = false;
  97.             holdBall_mc.hold_mc.unloadMovie();
  98.             hold_mx.num = 0;
  99.          }
  100.       }
  101.    }
  102.    holdBall_mc.hold_mc.show_txt.text = 3 - hold_mx.num;
  103. }
  104. function push_balls(obj, _speed)
  105. {
  106.    if(!Allstop)
  107.    {
  108.       obj.pos += _speed;
  109.    }
  110.    else
  111.    {
  112.       obj.pos += 0;
  113.    }
  114.    updatePos(obj,_speed,false);
  115.    if(obj.right._name != undefined)
  116.    {
  117.       if(obj._currentframe < 12)
  118.       {
  119.          return push_balls(obj.right,_speed);
  120.       }
  121.       remove_movie_end(obj.remove_id);
  122.    }
  123.    return obj;
  124. }
  125. function pull_balls(obj, _speed)
  126. {
  127.    obj.pos += _speed;
  128.    trace(" carry from pull_balls ");
  129.    updatePos(obj,_speed,false);
  130.    if(obj.left._name != undefined)
  131.    {
  132.       return pull_balls(obj.left,_speed);
  133.    }
  134.    return obj;
  135. }
  136. function find_break_ball(obj)
  137. {
  138.    if(obj.left._name != undefined)
  139.    {
  140.       return find_break_ball(obj.left);
  141.    }
  142.    return obj;
  143. }
  144. function find_last()
  145. {
  146.    var _loc1_ = undefined;
  147.    if(last_ball._name == undefined)
  148.    {
  149.       _loc1_ = firstBall;
  150.    }
  151.    else
  152.    {
  153.       _loc1_ = last_ball;
  154.    }
  155.    while(_loc1_.right._name != undefined || _loc1_.link_right._name != undefined)
  156.    {
  157.       if(_loc1_.right._name != undefined)
  158.       {
  159.          _loc1_ = _loc1_.right;
  160.       }
  161.       else if(_loc1_.link_right._name != undefined)
  162.       {
  163.          _loc1_ = _loc1_.link_right;
  164.       }
  165.    }
  166.    last_ball = _loc1_;
  167.    if(last_ball._name != undefined)
  168.    {
  169.       last_pos = last_ball.pos;
  170.       last_pos -= last_pos % posXishu;
  171.    }
  172. }
  173. function goback_all_balls()
  174. {
  175.    var _loc1_ = firstBall;
  176.    _loc1_.pos += all_forward_speed;
  177.    trace(all_forward_speed);
  178.    updatePos(_loc1_,all_forward_speed,false);
  179.    trace(" carry from goback_all_balls ");
  180.    while(_loc1_.right._name != undefined || _loc1_.link_right._name != undefined)
  181.    {
  182.       if(_loc1_.right._name != undefined)
  183.       {
  184.          _loc1_ = _loc1_.right;
  185.       }
  186.       else if(_loc1_.link_right._name != undefined)
  187.       {
  188.          _loc1_ = _loc1_.link_right;
  189.       }
  190.       _loc1_.pos += all_forward_speed;
  191.       trace(" carry from all_forward_speed ");
  192.       updatePos(_loc1_,all_forward_speed,false);
  193.    }
  194. }
  195. function align_left_balls(obj)
  196. {
  197.    while(obj._name != undefined)
  198.    {
  199.       obj.pos = obj.left.pos + posXishu;
  200.       obj = obj.right;
  201.    }
  202. }
  203. function align_right_balls(obj)
  204. {
  205.    while(obj._name != undefined)
  206.    {
  207.       obj.pos = obj.right.pos - posXishu;
  208.       obj = obj.left;
  209.    }
  210. }
  211. function break_array_pop(obj)
  212. {
  213.    i = 0;
  214.    while(i < break_array.length)
  215.    {
  216.       if(break_array[i] == obj)
  217.       {
  218.          obj.goback_speed = 0;
  219.          obj.goback_speed2 = 0;
  220.          break_array.splice(i,1);
  221.          break;
  222.       }
  223.       i++;
  224.    }
  225. }
  226. function getNewType(oldtype)
  227. {
  228.    if(tgt_same_num < tgt_same_total)
  229.    {
  230.       return oldtype;
  231.    }
  232.    tgt_same_num = 0;
  233.    tgt_same_total = tgt_same_base + random(tgt_same_change);
  234.    do
  235.    {
  236.       var newType = random(tgt_type) + 1;
  237.    }
  238.    while(newType == oldtype);
  239.    
  240.    return newType;
  241. }
  242. function mcDistance(mc0, mc1)
  243. {
  244.    var _loc2_ = mc0._x - mc1._x;
  245.    var _loc1_ = mc0._y - mc1._y;
  246.    return Math.sqrt(_loc2_ * _loc2_ + _loc1_ * _loc1_);
  247. }
  248. function mcDistance2(mc0, mc1)
  249. {
  250.    return Math.abs(mc0.pos - mc1.pos);
  251. }
  252. function setTag(obj, tag_bool)
  253. {
  254.    obj.tag = "";
  255.    if(!(random(tagTime) == 0 && tag_bool))
  256.    {
  257.       obj.flower.tag_mc.stop();
  258.       obj.flower.tag_mc._visible = false;
  259.    }
  260. }
  261. function setMotherDir(rada)
  262. {
  263.    if(dir_bool)
  264.    {
  265.       var _loc1_ = new Object();
  266.       var _loc3_ = new Object();
  267.       var _loc2_ = new Object();
  268.       _loc1_.x = ball.x;
  269.       _loc1_.y = ball.y;
  270.       _loc1_ = find_dir(_loc1_,rada);
  271.       _loc3_.x = Math.round(ball.x - 3 * Math.sin(rada));
  272.       _loc3_.y = Math.round(ball.y + 3 * Math.cos(rada));
  273.       _loc2_.x = Math.round(ball.x + 3 * Math.sin(rada));
  274.       _loc2_.y = Math.round(ball.y - 3 * Math.cos(rada));
  275.       dir_mc.clear();
  276.       dir_mc.beginFill(16711680,30);
  277.       dir_mc.moveTo(_loc1_.x,_loc1_.y);
  278.       dir_mc.lineTo(_loc3_.x,_loc3_.y);
  279.       dir_mc.lineTo(_loc2_.x,_loc2_.y);
  280.       dir_mc.lineTo(_loc1_.x,_loc1_.y);
  281.       dir_num++;
  282.       trace(dir_num + ":" + dir_num_total);
  283.       if(dir_num >= dir_num_total)
  284.       {
  285.          dir_bool = false;
  286.          dir_mc.clear();
  287.       }
  288.    }
  289. }
  290. function outOfScene(pos)
  291. {
  292.    return pos.x < 0 || pos.y < 0 || pos.x > sceneWidth || pos.y > sceneHeight || mouth_start.pro_area.hitTest(pos.x,pos.y,true);
  293. }
  294. function find_dir(pos, rada)
  295. {
  296.    var _loc4_ = undefined;
  297.    var _loc2_ = width * 2 - 1;
  298.    while(!outOfScene(pos))
  299.    {
  300.       pos.x += _loc2_ * Math.cos(rada);
  301.       pos.y += _loc2_ * Math.sin(rada);
  302.    }
  303.    return pos;
  304. }
  305. function ball_boom(boom_obj)
  306. {
  307.    _root.Boom_blo = true;
  308.    _root.boom_num = 0;
  309.    if(firstBall._name != undefined && boom_obj._name != undefined)
  310.    {
  311.       var _loc3_ = firstBall;
  312.       var _loc6_ = random(65535);
  313.       if(mcDistance(boom_obj,_loc3_) < boom_area && _root.jumpBall != true)
  314.       {
  315.          var _loc4_ = new Object();
  316.          _loc4_.tgt_remove_num = 0;
  317.          _loc4_.id = _loc6_;
  318.          _loc4_.remove_array = new Array();
  319.          _loc4_.remove_array.push(_loc3_);
  320.          remove_arr_array[_loc6_] = _loc4_;
  321.          _loc3_.remove_id = _loc6_;
  322.       }
  323.       while(_loc3_.right._name != undefined || _loc3_.link_right._name != undefined)
  324.       {
  325.          if(_loc3_.right._name != undefined)
  326.          {
  327.             _loc3_ = _loc3_.right;
  328.          }
  329.          else if(_loc3_.link_right._name != undefined)
  330.          {
  331.             _loc3_ = _loc3_.link_right;
  332.          }
  333.          if(mcDistance(boom_obj,_loc3_) < boom_area && _root.jumpBall != true)
  334.          {
  335.             _root.boom_num = _root.boom_num + 1;
  336.             _loc6_ = random(65535);
  337.             _loc4_ = new Object();
  338.             _loc4_.tgt_remove_num = 0;
  339.             _loc4_.id = _loc6_;
  340.             _loc4_.remove_array = new Array();
  341.             remove_arr_array[_loc6_] = _loc4_;
  342.             _loc3_.checkTag = false;
  343.             _loc3_.remove_id = _loc6_;
  344.             remove_arr_array[_loc6_].remove_array.push(_loc3_);
  345.             if(_loc3_.tag == "bo")
  346.             {
  347.                var _loc5_ = _loc3_.idnum;
  348.                var _loc7_ = _root.attachMovie("showTebieCartoon","showTebieCartoon" + _root.getNextHighestDepth(),_root.getNextHighestDepth());
  349.                _loc7_._x = _loc3_._x;
  350.                _loc7_._y = _loc3_._y;
  351.                trace(" what_sig = " + _loc5_);
  352.                _loc7_.pic.gotoAndStop(_loc5_);
  353.                var _loc2_ = 0;
  354.                while(_loc2_ < cha_arr.length)
  355.                {
  356.                   if(_loc5_ == cha_arr[_loc2_] && cha_arr2[_loc2_] != 1)
  357.                   {
  358.                      if(cha_arr[_loc2_] == "h")
  359.                      {
  360.                         _root.poop1.gotoAndStop(2);
  361.                      }
  362.                      else if(cha_arr[_loc2_] == "n")
  363.                      {
  364.                         _root.poop3.gotoAndStop(4);
  365.                      }
  366.                      else if(cha_arr[_loc2_] == "o")
  367.                      {
  368.                         _root.poop2.gotoAndStop(3);
  369.                      }
  370.                      else if(cha_arr[_loc2_] == "e")
  371.                      {
  372.                         _root.poop4.gotoAndStop(5);
  373.                      }
  374.                      else if(cha_arr[_loc2_] == "y")
  375.                      {
  376.                         _root.poop5.gotoAndStop(6);
  377.                      }
  378.                      cha_arr.splice(_loc2_,1);
  379.                      cha_arr2.splice(_loc2_,1);
  380.                      cha_has++;
  381.                   }
  382.                   if(cha_has >= 5)
  383.                   {
  384.                      cha_has = 0;
  385.                      cha_arr = ["h","o","n","e","y"];
  386.                      cha_arr2 = [0,0,0,0,0];
  387.                      re_back_func_();
  388.                      _root.attachMovie("movieClassMC","movieClassMC" + _root.getNextHighestDepth(),_root.getNextHighestDepth(),{_x:158,_y:172});
  389.                      next_leve_func();
  390.                      break;
  391.                   }
  392.                   _loc2_ = _loc2_ + 1;
  393.                }
  394.             }
  395.             _loc3_.gotoAndPlay("boom");
  396.             var _loc8_ = _root.attachMovie("appearPoint","appearPoint" + _root.getNextHighestDepth(),_root.getNextHighestDepth());
  397.             _loc8_._x = remove_array[i]._x;
  398.             _loc8_._y = remove_array[i]._y;
  399.             _loc8_.addItemPoint = 10;
  400.             myGrid.pop(_loc3_._x,_loc3_._y,_loc3_,"tgt_ball");
  401.             _loc3_.removing = true;
  402.          }
  403.       }
  404.    }
  405.    _root.Boom_blo = false;
  406. }
  407. function setLife(num)
  408. {
  409. }
  410. function setGoal(num)
  411. {
  412.    goal_total += num;
  413.    trace(_root.tebl * num);
  414.    _root.Σ╕èΣ╕Çσìèσêåµò░ += _root.tebl * num;
  415.    _root.Σ╕ïΣ╕Çσìèσêåµò░ += (1 - _root.tebl) * num;
  416.    goal_total_mc.getNum(goal_total,goal_total_mc.obj,"mynum",12);
  417. }
  418. function setLevel(level_str)
  419. {
  420.    trace(level_str + level_mc.getNum);
  421.    level_mc.getNum(level_str,level_mc.obj,"mynum",12);
  422. }
  423. function setTgt_bar()
  424. {
  425.    tgtNum_bar.getBallGS(tgt_totalNum - tgt_num,tgtNum_bar.obj,"mynum",12);
  426. }
  427. function initShowPara()
  428. {
  429.    tgtNum_bar.bar._width = 0;
  430.    life_mc.getNum(life,life_mc.obj,"mynum",12);
  431.    goal_total_mc.getNum(0,goal_total_mc.obj,"mynum",12);
  432.    level_mc.getNum("_",level_mc.obj,"mynum",12);
  433. }
  434. function winMove()
  435. {
  436.    _root.center_mc._rotation = 90;
  437.    line2.attachMovie("dot2","dot2" + last_pos,last_pos);
  438.    line2["dot2" + last_pos]._x = pos_array[Math.floor(last_pos / lineXishu)].x;
  439.    line2["dot2" + last_pos]._y = pos_array[Math.floor(last_pos / lineXishu)].y;
  440.    EndBall._x = pos_array[Math.floor(last_pos / lineXishu)].x;
  441.    EndBall._y = pos_array[Math.floor(last_pos / lineXishu)].y;
  442.    setGoal(10);
  443.    last_pos += posXishu;
  444.    if(last_pos >= pos_array.length * lineXishu - posXishu)
  445.    {
  446.       EndBall.removeMovieClip();
  447.       mouth.TX.gotoAndStop(1);
  448.       delete move_listener_mc.onEnterFrame;
  449.       mouth.attachMovie("shine2","shine",0);
  450.       levelUp_sound.start(0);
  451.    }
  452. }
  453. if(_root.unblack != undefined)
  454. {
  455.    _root.unblack = undefined;
  456. }
  457. var hold_mx = {};
  458. hold_mx.num = 0;
  459.